package pers.luchuan.stream.provider.service;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;

@EnableBinding(Source.class) // 可以理解为一个消息管道的定义
public class MessageSenderImpl implements MessageSender {

    @Resource
    private MessageChannel output;
    @Override
    public void send(Object msg) {
        output.send(MessageBuilder.withPayload(msg).build());// 创建并发送消息
    }
}
